#include <unistd.h>
#include "RequestQueue.h"

RequestQueue::RequestQueue(char* file, char character) : queue(file, character) {
}

RequestQueue::~RequestQueue() {
}

int RequestQueue::Send(RequestMessage requestMessage) {
	return this->queue.write(getpid(), requestMessage);
}

int RequestQueue::Receive(QueueRecord<RequestMessage>& request) {
	long mtype = 0;
	RequestMessage requestMessage;

	int result = this->queue.read(mtype, requestMessage);
	request.mtype = mtype;
	request.data = requestMessage;

	return result;
}

void RequestQueue::destroy() {
	this->queue.destroy();
}
